﻿using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Logging;

namespace RestfulApi.Filters
{
    public class MyExceptionFilterAttribute : Attribute, IExceptionFilter
    {
        public MyExceptionFilterAttribute(ILogger<MyExceptionFilterAttribute> logger)
        {
            Logger = logger;
        }

        public ILogger<MyExceptionFilterAttribute> Logger { get; }

        public void OnException(ExceptionContext context)
        {
            Logger.LogInformation(context.Exception.Message);
        }
    }
}
